﻿@using System.Web.Mvc.Ajax
@using System.Web.Mvc.Html
@using System.Web.Mvc;
@using WebUI.Areas.Reports.Models;
@model DirectoryOperationsViewModel
<script src="@Links.Scripts.tooltip_js" type="text/javascript"></script>
<script src="@Links.Scripts.diQuery_collapsiblePanel_js" type="text/javascript"></script>
<link href="@Links.Content.css.tooltip_css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        $(".collapsibleContainer").collapsiblePanel();
    });
</script>
@{
    var gridColumns = new List<WebGridColumn>();

    gridColumns.Add(new WebGridColumn
    {
        ColumnName = "ObjectName",
        Header = "File Name",
        Format = @<text>@Html.Popup((string)item.ObjectName, MVC.Reports.Summary.Actions.ActionNames.FileSummary, (int)item.ID, 'f')</text>
    });

    gridColumns.Add(new WebGridColumn
    {
        ColumnName = "FullPathName",
        Header = "Directory Path",
        Format = @<text>@Html.ToolTip((string)item.FullPathName, 10)</text>
    });
    gridColumns.Add(new WebGridColumn
    {
        ColumnName = "ServerName",
        Format = @<text>@Html.Popup((string)item.ServerName, MVC.Reports.Summary.Actions.ActionNames.MachineTopAccessors, (int)item.ID, 's')</text>
    });

    gridColumns.Add(new WebGridColumn
    {
        ColumnName = "UserAccount",
        Header = "User",
        Format = @<text>@Html.Popup((string)item.UserAccount, MVC.Reports.Summary.Actions.ActionNames.UserSummary, (int)item.ID, 'u')</text>
    });

    foreach (string column in Model.Columns.Keys)
    {
        if (Model.Columns[column])
        {
            gridColumns.Add(new WebGridColumn { ColumnName = column });
        }
    }


    int i = 0;
    foreach (var record in Model.DirectoryOperations)
    {
    <div class="collapsibleContainer" title='@record.Directory : @record.Operations.Count()'>
        @*<img src="data:image/png;base64,@System.Convert.ToBase64String(record.Chart)" alt="" />*@
        @{
        var gridId = "grid" + i.ToString();
        var grid = new WebGrid(source: record.Operations, rowsPerPage: int.Parse(WebUI.Resources.PageSize), ajaxUpdateContainerId: gridId);
            @grid.GetHtml(htmlAttributes: new { id = gridId }, tableStyle: "main_table", headerStyle: "columns_head",
columns: gridColumns);
                     i++;
        }
    </div>
    }
}
